﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 违章条款管理
/// </summary>
[Route("QHSEXySpecialtyClause/[action]")]
[ApiController]
public class QHSEXyViolationClauseController : ControllerBase
{
    private readonly QHSEXySpecialtyViolationService _specialtyViolationService;

    public QHSEXyViolationClauseController(QHSEXySpecialtyViolationService specialtyViolationService)
    {
        _specialtyViolationService = specialtyViolationService;
    }

    /// <summary>
    /// 违章条款列表
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEXyViolationClauseModel> data = await _specialtyViolationService.GetAsync();
        return AppResult.Status200OK(data: data);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> List1()
    {
        List<QHSEXyViolationClauseModel> data = await _specialtyViolationService.GetAsync();
        return AppResult.Status200OK(data: data);
    }

    /// <summary>
    /// 专业违章条款查询
    /// </summary>
    /// <returns></returns>
   [CustomAuthorize("hdv_qhse_data")]
    [HttpPost]
    public async Task<AppResult> ClausePage([FromBody] IdInputModel input)
    {
        var data = await _specialtyViolationService.GetByNameAsync(input);
        return AppResult.Status200OK(data: data);
    }

    /// <summary>
    /// 专业隐患条款查询
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    //[CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GetClause([FromBody] IdInputModel input)
    {
        var data = await _specialtyViolationService.GetByIdAsync(input);
        return AppResult.Status200OK(data: data);
    }

}

